package imageextractor

import (
	"strings"

	"gitee.com/guoliben/kydlp-doctotext/3rdparty/fileidentify"
	"gitee.com/guoliben/kydlp-doctotext/extractor_interface"
	"gitee.com/guoliben/kydlp-doctotext/imageextractor/ocr"
)

func Init(ocrEngineSwitch bool) error {
	return ocr.Init(ocrEngineSwitch)
}

func Destroy() {
	ocr.Destroy()
}

func BlockUntilOcrDone() {
	ocr.WgBlockUntilOcrDone()
}

func CloseChanAfterOcrDone() {
	ocr.CloseChanAfterOcrDone()
}

func GetAndPrintAllOcrResult() {
	ocr.GetAndPrintAllOcrResult()
}

func GetOcrResult() (interface{}, string, int64, string, string, string) {
	return ocr.GetOcrResult()
}

func TextExtractorFactory(filetype string) extractor_interface.TextExtractor {
	// 禁用图片OCR功能
	return extractor_interface.UnknownType{}

	switch strings.TrimSpace(filetype) {

	case fileidentify.ImageTypeBmp:
		fallthrough

	case fileidentify.ImageTypeJpeg:
		fallthrough

	case fileidentify.ImageTypePng:
		fallthrough

	case fileidentify.ImageTypeGif:
		fallthrough

	case fileidentify.ImageTypeTiff:
		return ocr.OcrEngine{}
	}
	return extractor_interface.UnknownType{}
}
